package com.rt.tmpt.utils.net;

import java.io.IOException;

public class SendToFTP {

	
	public static void sendFile(String serverAddress,String user,String password,String localPath,String ftpPath,String fileName) throws IOException  {
		/*
		if(ftpPath.trim().equals("")){
			ftpPath="/";
		}
		String path=ftpPath.substring(0,ftpPath.lastIndexOf("/"));
		FtpClient ftpClient = null;
        TelnetOutputStream out = null;
        FileInputStream input = null;
		try{
			//连接FTP服务器
			ftpClient = new FtpClient();
			ftpClient.openServer(serverAddress);
			ftpClient.login(user, password);
            if(path.length()!=0){
            	ftpClient.cd(path);
            }
            ftpClient.binary();
            
            //上传文件
            out = ftpClient.put(fileName);
            String file = localPath+fileName;
            File fileIn = new File(file);
            input = new FileInputStream(fileIn);
            byte[] b = new byte[(int)fileIn.length()];
            int c ;
            if((c=input.read(b))!=-1){
            	out.write(b,0,c);
            }
            out.flush();
		}finally{
		    if(input!=null)input.close();
		    if(out!=null)out.close();
		    if(ftpClient!=null)ftpClient.closeServer();
		}
		*/
	}
	public static void main(String args[]){
		try{
			SendToFTP.sendFile("www.ydcard.com", "", "", "c:/", "  ", "20110927172828.jpg");
		    System.out.println("上传成功！"); 
		}catch(IOException e){
			    System.out.println("上传失败！");
				e.printStackTrace();
		 }
	}
}
